/*
ID: guoxu1
PROG: calfflac
LANG: C++
*/
//#include <iostream>
#include <fstream>
#include <vector>
using namespace std;

const int max_text_length = 20000;
const int max_pal_length = 2000;

int ord[256];

inline bool check( char* buf, int low, int high )
{
  while( ord[buf[low]] == ord[buf[high]] && low <= high )
  {
    while( ord[ buf[++low] ] == -1 );
    while( ord[ buf[--high] ] == -1 );
  }
  return ( low > high );
}

int main()
{
  for( int i = 0; i < 256; i++ ) ord[i] = -1;
  for( int i = 'A'; i <= 'Z'; i++ ) ord[i] = i - 'A';
  for( int i = 'a'; i <= 'z'; i++ ) ord[i] = i - 'a';

  ifstream fin( "calfflac.in" );
  ofstream fout( "calfflac.out" );

  char buf[ max_text_length ] = {0};
  fin.read( buf, max_text_length );
  int count = fin.gcount();

  vector<int> chars[ 26 ];

  for( int i = 0; i < count; i++ )
  {
    int o = ord[buf[i]];
    if( o != -1 )
    {
      chars[o].push_back( i );
    }
  }

  pair<int,int> longest( 0, 0 );

  for( int i = 0; i < 26; i++ )
  {
    vector<int>& charset = chars[i];
    if( charset.size() < 2 ) continue;
    for( size_t u = 0; u < charset.size() - 1; u++ )
    {
      for( size_t v = charset.size() - 1; v > u; v-- )
      {
        int high = charset[v];
        int low = charset[u];

        if( high - low + 1 > max_pal_length ) 
        {
          continue;
        }
        if( high - low < longest.second - longest.first )
        {
          break;
        }
        if( !check( buf, low, high ) )
          continue;
        if( high - low > longest.second - longest.first 
        || low < longest.first )
        {
          longest.first = low;
          longest.second = high;
        }
      }
    }
  }

  int length = 0;
  for( int i = longest.first; i <= longest.second; i++ )
  {
    if( ord[ buf[i] ] != -1 ) length++;
  }
  fout << length << endl;
  for( int i = longest.first; i <= longest.second; i++ )
  {
    fout << buf[i];
  }
  fout << endl;
  return 0;
}

